package com.ruoyi.project.lely.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.R;
import com.ruoyi.common.SecurityUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.framework.aspectj.lang.annotation.DataSource;
import com.ruoyi.framework.aspectj.lang.enums.DataSourceType;
import com.ruoyi.project.lely.bean.dto.LyFeedbackDTO;
import com.ruoyi.project.lely.bean.entity.LyFeedback;
import com.ruoyi.project.lely.mapper.LyFeedbackMapper;
import com.ruoyi.project.lely.service.LyFeedbackService;
import org.springframework.stereotype.Service;

/**
 * @Desc: 意见反馈
 * @Author LuoYong
 * @Date 2022/1/17 18:14
 */
@DataSource(value = DataSourceType.SLAVE)
@Service
public class LyFeedbackServiceImpl extends ServiceImpl<LyFeedbackMapper, LyFeedback> implements LyFeedbackService {

    @Override
    public R add(LyFeedbackDTO dto) {
        LyFeedback feedback = new LyFeedback();
        BeanUtils.copyProperties(dto, feedback);
        feedback.setUserId(SecurityUtils.getUserId());
        feedback.setUsername(SecurityUtils.getUsername());
        boolean b = this.saveOrUpdate(feedback);
        return b ? R.ok("操作成功") : R.fail("操作失败");
    }
}
